#ifndef CPFS_COMMON_H
#define CPFS_COMMON_H

#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <limits.h>
#include <string.h>
#include <time.h>
//
#include <algorithm>
//#include <ext/hash_map>
#include <map>
#include <memory>
#include <stdexcept>
#include <set>
#include <type_traits>
#include <vector>
//
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/strong_typedef.hpp>
//
#include <cxutil/logging.h>
#include <cxutil/utility.h>
#include <cxutil/compat.h>
//
#include "cpfs.h"
//
#include "types.h"
#include "device.h"
#include "error.h"

class CpfsError : public std::exception {
public:
    CpfsError(CpfsErrno const fserrno) : fserrno(fserrno) {
        assert(fserrno != NoError);
    }
    CpfsErrno const fserrno;
    char const *what() const override throw() {
        return cpfs_errno_str(fserrno);
    }
};
class SystemError : public std::runtime_error {
public:
    SystemError(char const *desc, int errno__ = errno)
        :   std::runtime_error(
                str(boost::format("%s: %s") % desc % strerror(errno__))) {
    }
};
typedef std::logic_error AssertionError;

#endif
